<?php

//测试函数
function test(){
    echo 'this is test function ';
}

/**
 * @param $data  需要遍历的数组
 * @param int $ps_pid  当前权限的父id
 * @return array 整理后的数组
 */
function recursionTree($data,$ps_pid=0){
    static $arr = [];
    foreach($data as $val){
        if($val['ps_pid']==$ps_pid){
            $arr[] = $val;
            recursionTree($data,$val['ps_id']);
        }
    }
    return $arr;
}

/**
 * 获取当前控制器名
 */
function getCurrentControllerName()
{
    return getCurrentAction()['controller'];
}

/**
 * 获取当前方法名
 */
function getCurrentMethodName()
{
    return getCurrentAction()['method'];
}


/**
 * 获取当前控制器与操作方法的通用函数
 */
function getCurrentAction()
{
    $action = \Route::current()->getActionName();
    //dd($action);exit;
    //dd($action);
    list($class, $method) = explode('@', $action);
    //$classes = explode(DIRECTORY_SEPARATOR,$class);
    $class = str_replace('Controller','',substr(strrchr($class,DIRECTORY_SEPARATOR),1));

    return ['controller' => $class, 'method' => $method];
}
